﻿using Dilon.Core.Service;
using Furion.TaskScheduler;
using Microsoft.EntityFrameworkCore;
using SqlSugar;
using System;
using System.ComponentModel.DataAnnotations.Schema;

namespace Dilon.Core
{
    /// <summary>
    /// 定时任务
    /// </summary>
    [SugarTable("sys_timer", TableDescription = "定时任务表")]
    public class SysTimer : DEntityBase
    {
        /// <summary>
        /// 任务名称
        /// </summary>
        /// <example>dilon</example>
         [SugarColumn(ColumnDescription="任务名称", IsNullable = true)]
        public string JobName { get; set; }

        /// <summary>
        /// 执行间隔时间（单位秒）
        /// </summary>
        /// <example>5</example>
         [SugarColumn(ColumnDescription="间隔时间")]
        public int? Interval { get; set; } = 5;

        /// <summary>
        /// Cron表达式
        /// </summary>
        /// <example></example>
         [SugarColumn(ColumnDescription="Cron表达式", IsNullable = true)]
        public string Cron { get; set; }

        /// <summary>
        /// 定时器类型
        /// </summary>
         [SugarColumn(ColumnDescription="定时器类型")]
        public SpareTimeTypes TimerType { get; set; } = SpareTimeTypes.Interval;

        /// <summary>
        /// 执行次数
        /// </summary>
         [SugarColumn(ColumnDescription="执行次数",IsNullable = true)]
        public int? RunNumber { get; set; }

        /// <summary>
        /// 请求url
        /// </summary>
         [SugarColumn(ColumnDescription="请求url", IsNullable = true)]
        public string RequestUrl { get; set; }

        /// <summary>
        /// 请求参数（Post，Put请求用）
        /// </summary>
         [SugarColumn(ColumnDescription="请求参数", IsNullable = true)]
        public string RequestParameters { get; set; }

        /// <summary>
        /// Headers(可以包含如：Authorization授权认证)
        /// 格式：{"Authorization":"userpassword.."}
        /// </summary>
         [SugarColumn(ColumnDescription="Headers", IsNullable = true)]
        public string Headers { get; set; }

        /// <summary>
        /// 请求类型
        /// </summary>
        /// <example>2</example>
         [SugarColumn(ColumnDescription="请求类型")]
        public RequestTypeEnum RequestType { get; set; } = RequestTypeEnum.Post;

        /// <summary>
        /// 备注
        /// </summary>
         [SugarColumn(ColumnDescription="备注", IsNullable = true)]
        public string Remark { get; set; }
    }
}
